package com.xbongbong.saas.enums.business;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.enums.ScreenTypeEnum;
import com.xbongbong.saas.enums.SetTypeEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import com.xbongbong.saas.enums.base.ContractBaseEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * @author wujian
 * @version v1.0
 * @date 2020/12/22 22:00
 * @since v1.0
 */
@Getter
public enum  OrderEnum {
    //订货单模版字段
    //基础信息
    /**
     *other_1
     * 基础信息
     */
    BASE_INFO(ContractBaseEnum.BASE_INFO.getAttr(), "enum.order.attrName.base_info", "baseInfo",FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 10000, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * serialNo
     * 订单编号
     */
    ORDER_NO(ContractBaseEnum.CONTRACT_NO.getAttr(),"enum.order.attrName.order_no", "orderNo", FieldTypeEnum.SERIALNO.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9990, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * text_2
     * 关联经销商
     */
    LINK_DISTRIBUTOR(ContractBaseEnum.LINK_CUSTOMER.getAttr(), "enum.order.attrName.link_distributor", "linkDistributor", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9970, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * text_6
     * 订单状态
     */
    STATUS(ContractBaseEnum.STATUS.getAttr(), "enum.order.attrName.status", "status", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.LIST_DETAIL.getCode(), 9910, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * text_8
     * 签订人
     */
    SIGN_PERSON(ContractBaseEnum.SIGN_PERSON.getAttr(), "enum.order.attrName.sign_person", "signPerson", FieldTypeEnum.USER.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9940, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),

    /**
     * date_1
     * 下单日期
     */
    SIGN_TIME(ContractBaseEnum.SIGN_TIME.getAttr(), "enum.order.attrName.sign_time", "signTime", FieldTypeEnum.DATETIME.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9930, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * date_2
     * 交货日期
     */
    DEADLINE(ContractBaseEnum.DEADLINE.getAttr(), "enum.order.attrName.deadline", "deadLine", FieldTypeEnum.DATETIME.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9920, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),

    /**
     * ownerId
     * 负责人
     */
    OWNER_ID(ContractBaseEnum.OWNER_ID.getAttr(), "enum.order.attrName.owner_id", "ownerId", FieldTypeEnum.OWNERID.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9900, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * coUserId
     * 协同人
     */
    MINOR_USER(ContractBaseEnum.MINOR_USER.getAttr(), "enum.order.attrName.minor_user", "coUserId", FieldTypeEnum.COUSERID.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9890, 1, 0, ScreenTypeEnum.SCREEN_SEARCH.getType()),
    // 订货信息
    /**
     * other_2
     * 订货信息
     */
    SALE_INFO(ContractBaseEnum.SALE_INFO.getAttr(), "enum.order.attrName.sale_info", "saleInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9880, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * array_4
     * 关联产品
     */
    PRODUCT(ContractBaseEnum.PRODUCT.getAttr(), "enum.order.attrName.product", "products", FieldTypeEnum.SELECT_PRODUCT.getType(), 2, 0, 0, ShowTypeEnum.ALL.getCode(), 9870, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_26
     * 产品合计
     */
    PRODUCT_TOTAL(ContractBaseEnum.PRODUCT_TOTAL.getAttr(),"enum.order.attrName.product_total", "productTotal", FieldTypeEnum.NUM.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9860, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    //优惠金额
    /**
     * num_28
     * 优惠金额
     */
    DISCOUNT_AMOUNT(ContractBaseEnum.DISCOUNT_AMOUNT.getAttr(), "enum.order.attrName.discount_amount", "discountAmount", FieldTypeEnum.NUM.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9840, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_1
     * 订单金额
     */
    AMOUNT(ContractBaseEnum.AMOUNT.getAttr(), "enum.order.attrName.amount", "totalMoney", FieldTypeEnum.NUM.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9830, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_2
     * 订单成本
     */
    ORDER_COST(ContractBaseEnum.CONTRACT_COST.getAttr(), "enum.order.attrName.order_cost", "orderCost", FieldTypeEnum.NUM.getType(),SetTypeEnum.DISABLE_OPEN.getCode(), 0, 0, ShowTypeEnum.LIST_DETAIL.getCode(), 9820, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_25
     * 订单毛利
     */
    GROSS_PROFIT(ContractBaseEnum.GROSS_PROFIT.getAttr(), "enum.order.attrName.gross_profit", "grossProfit", FieldTypeEnum.NUM.getType(), SetTypeEnum.DISABLE_OPEN.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 9810, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_3
     * 订单毛利率
     */
    GROSS_PROFIT_RATE(ContractBaseEnum.GROSS_PROFIT_RATE.getAttr(), "enum.order.attrName.gross_profit_rate", "grossProfitRate", FieldTypeEnum.NUM.getType(), SetTypeEnum.DISABLE_OPEN.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 9800, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_4
     * 现金毛利
     */
    CASH_PROFIT(ContractBaseEnum.CASH_PROFIT.getAttr(), "enum.order.attrName.cash_profit", "cashProfit", FieldTypeEnum.NUM.getType(), SetTypeEnum.DISABLE_OPEN.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 9790, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_5
     * 现金毛利率
     */
    CASH_PROFIT_RATE(ContractBaseEnum.CASH_PROFIT_RATE.getAttr(), "enum.order.attrName.cash_profit_rate", "cashProfitRate", FieldTypeEnum.NUM.getType(), SetTypeEnum.DISABLE_OPEN.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 9780, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * 资金管理一期改造，将以下字段进行修改，并新增
     * 修改字段：
     * 关联信息-->关联回款
     * 添加应收款-->应收款
     * 新增字段：
     * 坏账金额，坏账金额的变化由回款单的变化而变化
     * 核销预收款
     * 回款单
     */
    // 关联信息
    /**
     * other_3
     * 关联回款
     */
    ASSOCIATED_INFO(ContractBaseEnum.ASSOCIATED_INFO.getAttr(), "enum.order.attrName.associated_info", "associatedInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9770, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * button_2
     * 回款单
     */
    ADD_PAYMENT_SHEET(ContractBaseEnum.ADD_PAYMENT_SHEET.getAttr(), "enum.order.attrName.add_payment_sheet", "addPaymentSheet", FieldTypeEnum.LINK_FORM_BUTTON.getType(), 3, 0, 0, ShowTypeEnum.EDIT.getCode(), 9768, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * button_1
     * 核销预收款
     */
    ADD_WRITE_OFF_PREPAYMENT(ContractBaseEnum.ADD_WRITE_OFF_PREPAYMENT.getAttr(), "enum.order.attrName.add_write_off_prepayment", "addWriteOffPrepayment", FieldTypeEnum.LINK_FORM_BUTTON.getType(), 3, 0, 0, ShowTypeEnum.EDIT.getCode(), 9769, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * 新回款计划
     * array_1
     */
    ADD_PAYMENT(ContractBaseEnum.ADD_PAYMENT.getAttr(), "enum.order.attrName.add_payment", "addPayment", FieldTypeEnum.LINK_FORM.getType(), 3, 0, 0, ShowTypeEnum.EDIT.getCode(), 9760, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),

    // 发货信息
    /**
     * other_4
     * 发货信息
     */
    SHIP_INFO(ContractBaseEnum.EXTEND_INFO.getAttr(), "enum.order.attrName.ship_info", "shipInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9750, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * text_5
     * 收货人
     */
    LINK_PARTNER_RECEIVER(ContractBaseEnum.LINK_PARTNER_CUSTOMER.getAttr(),"enum.order.attrName.link_partner_receiver", "linkPartnerReceiver", FieldTypeEnum.LINK_RECEIVER.getType(), 2, 0, 0, ShowTypeEnum.ALL.getCode(), 9740, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * text_82
     * 联系电话
     */
    LINK_CONTACT_NUMBER("text_82", "enum.order.attrName.link_contact_number", "linkContactNumber", FieldTypeEnum.TEXT.getType(), 3, 0, 0, ShowTypeEnum.ALL.getCode(), 9740, 1, 0, ScreenTypeEnum.SCREEN_SHOW.getType()),
    /**
     * address_2
     * 收货地址
     */
    SHIPPING_ADDRESS("address_2", "enum.order.attrName.link_shipping_address", "linkShippingAddress", FieldTypeEnum.ADDRESS.getType(),3, 0, 0, ShowTypeEnum.ALL.getCode(), 9740, 1, 0, ScreenTypeEnum.SCREEN_SHOW.getType()),

    //拓展信息 下单类型
    /**
     * other_16
     * 拓展信息
     */
    EXTEND_INFO("other_16", "enum.order.attrName.extend_info", "extendInfo",  FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9680, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * text_13
     * 出库状态
     */
    SHIP_STATUS(ContractBaseEnum.SHIP_STATUS.getAttr(),"enum.order.attrName.ship_status","shipStatus",FieldTypeEnum.COMBO.getType(),1,1,0,ShowTypeEnum.LIST_DETAIL.getCode(),9370,1,0,ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * text_83
     * 收款状态
     * @see com.xbongbong.saas.enums.dictionary.OrderPayMentStatusEnum
     */
    RECEIVE_PAYMENT_STATUS("text_83", "enum.order.attrName.receive_payment_status","receivePaymentStatus",FieldTypeEnum.COMBO.getType(),1,1,0,ShowTypeEnum.LIST_DETAIL.getCode(),9370,1,0,ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * text_10
     * 发货状态
     */
    EXPRESS_STATUS(ContractBaseEnum.EXPRESS_STATUS.getAttr(), "enum.order.attrName.express_status", "expressStatus", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.LIST_DETAIL.getCode(), 9710, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * text_7
     * 下单类型
     */
    TYPE(ContractBaseEnum.TYPE.getAttr(), "enum.order.attrName.type", "type", FieldTypeEnum.COMBO.getType(), 1, 0, 0, ShowTypeEnum.LIST_DETAIL.getCode(), 9730, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * text_84
     * 备注
     */
    MEMO("text_84", "enum.order.attrName.memo", "memo", FieldTypeEnum.TEXTAREA.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 9870, 1, 0, ScreenTypeEnum.SCREEN_SHOW.getType()),
//    PAY_METHOD(ContractBaseEnum.PAY_METHOD.getAttr(), "enum.contract.attrName.pay_method", "payMethod", FieldTypeEnum.COMBO.getType(), 3, 0, 0, ShowTypeEnum.LIST_DETAIL.getCode(), 9720, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),

    // 系统信息
    /**
     * other_5
     * 系统信息
     */
    SYSTEM_INFO(ContractBaseEnum.SYSTEM_INFO.getAttr(), "enum.order.attrName.system_info", "systemInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 9680, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * long_1
     * 下单人ID
     */
    ORDERER_ID("long_1","enum.order.attrName.orderer_id","ordererId",FieldTypeEnum.LONG.getType(),1, 0, 1, ShowTypeEnum.NONE.getCode(), 9670, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     *  text_85
     *  下单人
     */
    ORDERER("text_85", "enum.order.attrName.orderer","orderer", FieldTypeEnum.TEXT.getType(), 1,0, 1, ShowTypeEnum.LIST_DETAIL.getCode(), 9670, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * creatorId
     * 创建人
     */
    CREATOR_ID(ContractBaseEnum.CREATOR_ID.getAttr(), "enum.order.attrName.creator_id", "creatorId", FieldTypeEnum.CREATORID.getType(), 1, 0, 0, ShowTypeEnum.ALL.getCode(), 9670, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * addTime
     * 创建时间
     */
    ADD_TIME(ContractBaseEnum.ADD_TIME.getAttr(), "enum.order.attrName.add_time", "addTime", FieldTypeEnum.ADDTIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9660, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * updateTime
     * 更新时间
     */
    UPDATE_TIME(ContractBaseEnum.UPDATE_TIME.getAttr(),"enum.order.attrName.update_time", "updateTime", FieldTypeEnum.UPDATETIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 9650, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    // 须在列表页展示，不在新建和表单设计展示
    /**
     * num_6
     * 已收金额
     */
    FINISH_AMOUNT(ContractBaseEnum.FINISH_AMOUNT.getAttr(), "enum.order.attrName.finish_amount", "finishAmount", FieldTypeEnum.NUM.getType(), 1, 0, 1, ShowTypeEnum.LIST.getCode(), 9640, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_7
     * 未收金额
     */
    UN_FINISH_AMOUNT(ContractBaseEnum.UN_FINISH_AMOUNT.getAttr(), "enum.order.attrName.un_finish_amount", "unFinishAmount", FieldTypeEnum.NUM.getType(), 1, 0, 1, ShowTypeEnum.LIST.getCode(), 9630, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_31
     * 坏账金额
     */
    BAD_AMOUNT(ContractBaseEnum.BAD_AMOUNT.getAttr(), "enum.order.attrName.bad_amount", "badAmount", FieldTypeEnum.NUM.getType(), 1, 0, 1, ShowTypeEnum.LIST.getCode(), 9629, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_8
     * 收款比例
     */
    PAY_PERCENT(ContractBaseEnum.PAY_PERCENT.getAttr(), "enum.order.attrName.pay_percent", "payPercent", FieldTypeEnum.NUM.getType(), 1, 0, 1, ShowTypeEnum.LIST.getCode(), 9620, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_9
     * 开票金额
     */
    INVOICE_AMOUNT(ContractBaseEnum.INVOICE_AMOUNT.getAttr(),"enum.order.attrName.invoice_amount", "invoiceAmount", FieldTypeEnum.NUM.getType(), 1, 0, 1, ShowTypeEnum.LIST.getCode(), 9610, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    /**
     * num_10
     * 未开票金额
     */
    UN_INVOICE_AMOUNT(ContractBaseEnum.UN_INVOICE_AMOUNT.getAttr(), "enum.order.attrName.un_invoice_amount", "unInvoiceAmount", FieldTypeEnum.NUM.getType(), 1, 0, 1, ShowTypeEnum.LIST.getCode(), 9600, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    // 逻辑字段
    /**
     * num_13
     * 是否用于合同统计
     */
    IF_STATISTIC(ContractBaseEnum.IF_STATISTIC.getAttr(), "enum.order.attrName.if_statistic", "ifStatistic", FieldTypeEnum.COMBO_NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9590, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_14
     * 多币种id
     */
    CURRENCY(ContractBaseEnum.CURRENCY.getAttr(),"enum.order.attrName.currency", "currency", FieldTypeEnum.NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9580, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_15
     * 汇率
     */
    EXCHANGE_RATE(ContractBaseEnum.EXCHANGE_RATE.getAttr(), "enum.order.attrName.exchange_rate", "exchangeRate", FieldTypeEnum.NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9570, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * array_2
     * 入库单id
     */
    INSTOCK_ID(ContractBaseEnum.INSTOCK_ID.getAttr(), "enum.order.attrName.instock_id", "instockId", FieldTypeEnum.COMBO_CHECK.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9560, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * array_3
     * 出库单id
     */
    OUTSTOCK_ID(ContractBaseEnum.OUTSTOCK_ID.getAttr(), "enum.order.attrName.outstock_id", "outstockId", FieldTypeEnum.COMBO_CHECK.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9550, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_18
     * 采购单id
     */
    PURCHASE_ID(ContractBaseEnum.PURCHASE_ID.getAttr(), "enum.order.attrName.purchase_id", "purchaseId", FieldTypeEnum.NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9540, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_19
     * 是否出库完毕
     */
    ALL_OUT_BOUND(ContractBaseEnum.ALL_OUT_BOUND.getAttr(), "enum.order.attrName.all_out_bound", "allOutBound", FieldTypeEnum.COMBO_NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9530, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_20
     * 是否红冲
     */
    IS_RED(ContractBaseEnum.IS_RED.getAttr(), "enum.order.attrName.is_red", "isRed", FieldTypeEnum.COMBO_NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9520, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_21
     * 是否被红冲
     */
    HAS_RED(ContractBaseEnum.HAS_RED.getAttr(), "enum.order.attrName.has_red", "hasRed", FieldTypeEnum.COMBO_NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9510, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_22
     * 预计成本
     */
    ESTIMATE_COST(ContractBaseEnum.ESTIMATE_COST.getAttr(), "enum.order.attrName.estimate_cost", "estimateCost", FieldTypeEnum.NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9500, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_23
     * 实际成本
     */
    REAL_COST(ContractBaseEnum.REAL_COST.getAttr(), "enum.order.attrName.real_cost", "realCost", FieldTypeEnum.NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9490, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_24
     * 待缺货
     */
    SHOW_PRODUCE(ContractBaseEnum.SHOW_PRODUCE.getAttr(), "enum.order.attrName.show_produce", "showProduce", FieldTypeEnum.COMBO_NUM.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9480, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * text_18
     * 关联客户隐藏
     */
    LINK_CUSTOMER_HIDE(ContractBaseEnum.LINK_CUSTOMER_HIDE.getAttr(), "enum.order.attrName.link_customer_hide", "linkCustomerHide", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9470, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * text_86
     * 关联收货人隐藏
     */
    LINK_PARTNER_RECEIVER_HIDE("text_86","enum.order.attrName.link_partner_receiver_hide","linkPartnerReceiverHide",FieldTypeEnum.TEXT.getType(),1,0,1,ShowTypeEnum.NONE.getCode(),9490,1,1,ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * text_21
     * 合作经销商隐藏
     */
    // LINK_PARTNER_DISTRIBUTOR_HIDE(ContractBaseEnum.LINK_PARTNER_CUSTOMER_HIDE.getAttr(), "enum.order.attrName.link_partner_distributor_hide", "linkPartnerDistributorHide", FieldTypeEnum.TEXT.getType(), 3, 0, 1, ShowTypeEnum.NONE.getCode(), 9440, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * num_11
     * 归档状态
     */
    ARCHIVED(ContractBaseEnum.ARCHIVED.getAttr(), "enum.order.attrName.archived", "archived", FieldTypeEnum.COMBO_NUM.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9420, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * text_22
     * 签订人名称
     */
    SIGN_NAME(ContractBaseEnum.SIGN_NAME.getAttr(), "enum.order.attrName.sign_name", "signName", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 9420, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * array_5
     * 优惠券
     */
    COUPON_ID(ContractBaseEnum.COUPON_ID.getAttr(), "enum.order.attrName.coupon_id", "couponId", FieldTypeEnum.COMBO_CHECK.getType(), 1, 1, 1, ShowTypeEnum.NONE.getCode(), 9550, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    /**
     * text_81
     * 应收账期
     */
    RECEIVABLE_PERIOD(ContractBaseEnum.RECEIVABLE_PERIOD.getAttr(), "enum.customerManagement.attrName.receivable_period", "receivablePeriod", FieldTypeEnum.ACCOUNT_PERIOD.getType(), 3, 1, 0, ShowTypeEnum.ALL.getCode(), 9370, 1, 1, ScreenTypeEnum.SCREEN_SHOW.getType()),

    /**
     * num_62
     * 已出库优惠金额
     */
    OUTSTOCK_DISCOUNT_AMOUNT(ContractBaseEnum.OUTSTOCK_DISCOUNT_AMOUNT.getAttr(), "enum.distributorOrder.attrName.outstock_discount_amount", "outstockDiscountAmount", FieldTypeEnum.NUM.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 870, 0, 0, ScreenTypeEnum.SCREEN_OFF.getType()),

    ;

    /**
     * 英文名称
     */
    private String attr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 对应saas中的attr
     */
    private String saasAttr;
    /**
     * 字段类型，详见
     *
     * @see com.xbongbong.paas.enums.FieldTypeEnum
     */
    private Integer fieldType;
    /**
     * 重命名、判重、启用必填等权限
     * 1.重命名+字段权限
     * 2.重命名+字段权限+查重
     * 3.重命名+字段权限+启用、必填
     * 4.重命名+字段权限+查重+启用、必填
     * 注：pro中启用和必填是同一个权限，同时启用或同时关闭
     */
    private Integer setType;
    /**
     * 模板设计阶段字段是否允许编辑
     * 1：允许编辑
     * 0：不允许编辑
     */
    private Integer designEditable;
    /**
     * 字段是否显示在模板设计界面
     * 1：不显示
     * 0：显示
     */
    private Integer editHide;
    /**
     * 字段在各个界面（新建、编辑、列表、详情）的展现形式
     * 详见
     *
     * @see com.xbongbong.saas.enums.ShowTypeEnum
     */
    private Integer showType;
    /**
     * 字段在模板设计界面的排序
     * 建议不要用连续的数字，可以用等差数列，以防以后在两个字段之间加入新字段
     */
    private Integer sort;
    /**
     * 字段在各个界面是否可见(启用)
     * 1：可见
     * 0：不可见
     * 注：字段在具体页面的可见性需要用属性和showType联合判断，在visible=1的情况下判断showType
     */
    private Integer visible;
    /**
     * 字段是否必填
     * 1：必填
     * 0：不必填
     */
    private Integer required;
    /**
     * 筛选类型
     * 1：可筛选
     * 2：不可筛选
     */
    private Integer screenType;

    OrderEnum(String attr, String attrName, String saasAttr, Integer fieldType, Integer setType, Integer designEditable,
                 Integer editHide, Integer showType, Integer sort, Integer visible, Integer required, Integer screenType) {
        this.attr = attr;
        this.attrName = attrName;
        this.saasAttr = saasAttr;
        this.fieldType = fieldType;
        this.setType = setType;
        this.designEditable = designEditable;
        this.editHide = editHide;
        this.showType = showType;
        this.sort = sort;
        this.visible = visible;
        this.required = required;
        this.screenType = screenType;
    }
    /**
     * 对data内的字段拼上“data.”
     *
     * @param cache
     * @return java.lang.String
     * @author zcp
     * @date 2019/3/1 18:12
     * @version v1.0
     * @since v1.0
     */
    public static String getAttrConnectData(OrderEnum cache) {
        return "data." + cache.getAttr();
    }

    /**
     * 获取es查询、聚合字段
     * data在库内是json对象，对data字段内某个key做es【精确查询】时，需要在其前拼上“data.”，且【text等类型的】要在后面拼“.keyword”
     *
     * @param cache 当前枚举对象
     * @return java.lang.String 处理后的聚合字段
     * @author zcp
     * @date 2019/2/21 14:59
     * @version v1.0
     * @since v1.0
     */
    public static String getEsAttr4Keyword(OrderEnum cache) {
        FieldTypeEnum fieldTypeEnum = FieldTypeEnum.getFieldTypeEnum(cache.fieldType);
        //字段类型为text，或者字段在es内的类型时text，则需要在后面拼上“.keyword”
        boolean flag = fieldTypeEnum == FieldTypeEnum.TEXT || "text".equals(fieldTypeEnum.getEsalias());
        if (flag) {
            return "data." + cache.getAttr() + ".keyword";
        }
        return "data." + cache.getAttr();
    }

//    public static List<JSONObject> getWaitTabHeadd() {
//        JSONObject radioCheck = new JSONObject();
//        radioCheck.put("prop", FieldTypeEnum.HEAD_CHECKBOX_GROUP.getAlias());
//        radioCheck.put("fieldType", FieldTypeEnum.HEAD_CHECKBOX_GROUP.getType());
//        radioCheck.put("label", FieldTypeEnum.HEAD_CHECKBOX_GROUP.getDescription());
//        JSONObject orderName = new JSONObject();
//        orderName.put("prop", "orderName");
//        orderName.put("fieldType", OrderEnum.NAME.fieldType);
//        orderName.put("label", OrderEnum.NAME.getAttrName());
//        JSONObject orderNo = new JSONObject();
//        orderNo.put("prop", "orderNo");
//        orderNo.put("fieldType", OrderEnum.ORDER_NO.fieldType);
//        orderNo.put("label", OrderEnum.ORDER_NO.getAttrName());
//        JSONObject customerName = new JSONObject();
//        customerName.put("prop", "customerName");
//        customerName.put("fieldType", OrderEnum.LINK_CUSTOMER.fieldType);
//        customerName.put("label", OrderEnum.LINK_CUSTOMER.getAttrName());
//        return Arrays.asList(radioCheck, orderName, orderNo, customerName);
//
//    }

    /**
     * 流程中获取隐藏字段
     *
     * @return
     */
    public static List<OrderEnum> getDisableField() {
        List<OrderEnum> OrderEnums = new ArrayList<>();
        for (OrderEnum orderEnum : values()) {
            if (Objects.equals(orderEnum.getShowType(), ShowTypeEnum.NONE.getCode()) || Objects.equals(orderEnum.getEditHide(), 1)
                    || Objects.equals(orderEnum.getFieldType(), FieldTypeEnum.CREATORID.getType()) || Objects.equals(orderEnum.getFieldType(), FieldTypeEnum.ADDTIME.getType())) {
                OrderEnums.add(orderEnum);
            }
        }
        return OrderEnums;
    }

    /**
     * app端详情默认标题显示字段
     *
     * @return List
     * @author GuoJun.HU
     * @date 2019/4/8 19:21
     * @since V1.0
     */
    public static List<Object> getTitleAttrList() {
        return Collections.singletonList(ORDER_NO);
    }

    /**
     * 默认标签
     *
     * @author long.rao
     * @date 2019-06-27 15:36
     */
    public static List<Object> getLabelAttrList() {
        return Collections.singletonList(STATUS);
    }

    /**
     * 详情默认摘要
     *
     * @author long.rao
     * @date 2019-06-27 15:47
     */
    public static List<Object> getSummaryAttrList() {
        return Arrays.asList(SIGN_PERSON, SIGN_TIME);
    }

    /**
     * 把传入的字段（类型为LINK_BUSINESS_SINGLE）的转为其隐藏字段
     * @param attr 字段名
     * @return java.lang.String
     * @author zcp
     * @date 2019/7/4 15:31
     * @since v1.0
     * @version v1.0
     */
    public static String changeToHide4Link(String attr) {
//        if (Objects.equals(attr, LINK_CUSTOMER.attr)) {
//            return LINK_CUSTOMER_HIDE.attr;
//        } else if (Objects.equals(attr, LINK_CONTACT.attr)) {
//            return LINK_CONTACT_HIDE.attr;
//        } else if (Objects.equals(attr, LINK_OPPORTUNITY.attr)) {
//            return LINK_OPPORTUNITY_HIDE.attr;
//        } else if (Objects.equals(attr, LINK_PARTNER_CUSTOMER.attr)) {
//            return LINK_PARTNER_CUSTOMER_HIDE.attr;
//        } else if (Objects.equals(attr, QUOTATION_ID.attr)) {
//            return QUOTATION_NAME.attr;
//        }
        return attr;
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }

}
